//初始数据
export const initState = {
    userInfo: sessionStorage.getItem("info")?JSON.parse(sessionStorage.getItem("info")):{},
    pre: "http://localhost:1000",
    n:0,
    
}
// 修改数据
export const reducer = (state, action) => {
    switch (action.type) {
        case "changeUserInfo":
            // {type:"changeUserInfo",userInfo:{token:"11"}}
            return {
                ...state,
                userInfo: action.userInfo
            }
            break;
        default:
            return state;
    }
}
// actionCreators
export const actions = {
    changeUserInfo: userInfo => {
        if (userInfo.token) {
            sessionStorage.setItem("info", JSON.stringify(userInfo))
        } else {
            sessionStorage.removeItem("info")
        }
        return { type: "changeUserInfo", userInfo }
    }
}
